<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.*"%>
<%@page import="com.manage.area.AreaVo"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
List<AreaVo> list = (List)request.getAttribute("squList");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>

<script src='<%=path %>/js/jquery-1.9.1.min.js'> </script>

<link href="<%=path %>/images/css.css" rel="stylesheet" type="text/css">

<script type="text/javascript">
function addScolle(readBytes, totalBytes){
	if(readBytes < totalBytes){
      	document.getElementById('uploadbutton').disabled = true;
    	document.getElementById('file1').disabled = true;
    	var progressPercent = Math.ceil((readBytes / totalBytes) * 100);
    	document.getElementById('uploadbutton').value = progressPercent + '%';
        window.setTimeout("refreshProgress()", 1000);
    }
    else{
      	document.getElementById('uploadbutton').disabled = false;
      	document.getElementById('uploadbutton').value = '100%';
      	document.getElementById('uploadbutton').value = '上传';
  		document.getElementById('file1').disabled = false;
    }
}
function refreshProgress(){
    $.ajax({
    	type: "POST",
    	url: "<%=path %>/ajax/getUploadInfo.action",
    	data: "",
    	dataType:"text", //ajax返回值设置为text（json格式也可用它返回，可打印出结果，也可设置成json）
    	success: function(json){  
    		var obj = $.parseJSON(json);  //使用这个方法解析json
            var state = obj.ajaxResult;  //result是和action中定义的result变量的get方法对应的
            var resultObj = $.parseJSON(state);
            var readBytes = resultObj.readedBytes;
            var totalBytes = resultObj.totalBytes;
            addScolle(readBytes, totalBytes);
    	},
    	error: function(json){
     		return false;
    	}
    });
}

function startProgress(){
    document.getElementById('uploadbutton').value = '0%';
    document.getElementById('uploadbutton').disabled = true;
    window.setTimeout("refreshProgress()", 1000);
    return true;
}
function showMsg(msg){
	document.getElementById('showmsg').style.display = 'block';
	document.getElementById('showmsg').innerText = msg;
	window.setTimeout("hiddenMsg()", 3000);
}
function hiddenMsg(){
	document.getElementById('showmsg').style.display = 'none';
	document.getElementById('showmsg').innerText = '';
}
</script>
</head>

<body class="bg_003">
<div id="Layer2" style="position:absolute; width:514px; height:142px; z-index:2; left: 240px; top: 28px"> 
  <form action="<%=path %>/filemanage/uploadfile.action" enctype="multipart/form-data" method="post"
		onsubmit="return startProgress();">
    <table width="100%" border="0" height="100%" bgcolor="#CCCCFF" cellpadding="1" cellspacing="1">
      <tr bgcolor="#Ffffec"> 
        <td width="20%" height="74" align="right">*接收单位：</td>
        <td width="80%">
		   <table width="100%" border="0" height="100%">
		        <%
		        for(int i=0;i<list.size();i++){	
		        %>
		   		<tr>
					<td><input type="checkbox" name="reciver" value="<%=list.get(i).getMessager_id() %>"/><label><%=list.get(i).getName() %></label></td>
					<% i++;if(i<list.size()){ %>
					<td><input type="checkbox" name="reciver" value="<%=list.get(i).getMessager_id() %>"/><label><%=list.get(i).getName() %></label></td>
					<% } %>
					<% i++;if(i<list.size()){ %>
					<td><input type="checkbox" name="reciver" value="<%=list.get(i).getMessager_id() %>"/><label><%=list.get(i).getName() %></label></td>
					<% } %>
					<% i++;if(i<list.size()){ %>
					<td><input type="checkbox" name="reciver" value="<%=list.get(i).getMessager_id() %>"/><label><%=list.get(i).getName() %></label></td>
					<% } %>
					<% i++;if(i<list.size()){ %>
					<td><input type="checkbox" name="reciver" value="<%=list.get(i).getMessager_id() %>"/><label><%=list.get(i).getName() %></label></td>
					<% } %>
				</tr>
				<%} %>
		   </table>
         </td> </tr>
      <tr bgcolor="#Ffffec"> 
        <td width="20%" align="right">*附件：</td>
        <td width="80%">
          <input type="hidden" value="e:\\temp\\" id="uppath" name="uppath" />
          <input class="default" size=40 type="file" id="file1" name="upload" />
        </td> </tr>
      <tr bgcolor="#Ffffec"> 
        <td colspan="2" height="30"> 
          <div align="center"> 
            <input type="submit" value="上传" id="uploadbutton" />
            <input type="reset" value="重置" name="reset" /> </div></td></tr>
</table>
<br>
<div id="showmsg" style="display:none" align="center">

</div>  
</form>
</div>
<script type="text/javascript">
var msg = "${requestScope.rMsg}";
if(msg != ""){
	showMsg(msg);
}
</script>
</body>
</html>